<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>派车申请表</title>
    <link rel="stylesheet" href="../static/css/reset.css">
    <link rel="stylesheet" href="../static/plus/eleme.css">
    <link rel="stylesheet" href="../static/css/style_xia.css">
</head>
<body>
<div id="app" class="car-apply">
    <mt-header fixed title="派车申请表">
        <mt-button slot="left" icon="back" @click="goBack"></mt-button>
        <mt-button slot="right" icon="more" @click="sheetVisible = true;"></mt-button>
    </mt-header>
    <section class="content">
        <div class="item">
            <label class="label" for="">部门</label>
            <input class="text" type="text" v-model="apply.department" disabled>
        </div>
        <div class="item">
            <label class="label" for="">人员</label>
            <input class="text" type="text" v-model="apply.applicant" disabled>
        </div>
        <div class="item">
            <label class="label" for="">申请时间</label>
            <input class="text" type="text" v-model="apply.applyTime" disabled>
        </div>
        <div class="item">
            <label class="label" for="">本地或外省</label>
            <label class="address c-666" for="" :class="{color: area === 1}" @click="selectArea(1)">本地</label>
            <label class="address c-666" for="" :class="{color: area ===2}" @click="selectArea(2)">外省</label>
        </div>
        <div class="item">
            <label class="label" for="">出发地</label>
            <input class="text" type="text" v-model="apply.startArea">
        </div>
        <div class="item">
            <label class="label" for="">目的地</label>
            <input class="text" type="text" v-model="apply.endArea">
        </div>
        <div class="item select-num" @click="isShowBtnModel = true;">
            <label class="label" for="">数量</label>
            <span class="c-666" v-text="apply.num"></span>
        </div>
        <div class="item">
            <label class="label" for="">接受车型</label>
            <label v-for="(item,index) in carType" class="car-icon c-666" :class="{color: item.flag}" for=""
                   @click="changeCar(item)" v-text="item.name"></label>
        </div>
        <div class="item">
            <label class="label" for="">使用开始时间</label>
            <input v-model="apply.startTime" class="text" @click="showStarTime('picker1')">
        </div>
        <div class="item">
            <label class="label" for="">使用结束时间</label>
            <input v-model="apply.endTime" class="text" @click="showStarTime('picker2')">
        </div>
        <div class="item reason">
            <label class="label" for="">使用原因</label>
            <textarea name="" id="" rows="5" v-model="apply.reason"></textarea>
        </div>
        <div class="item send-btn">
            <button class="btn" @click="applyBth">提交</button>
        </div>
        <!--开始时间选择器-->
        <mt-datetime-picker
                ref="picker1"
                type="datetime"
                :start-date="startDate"
                @confirm="handleConfirmS">
        </mt-datetime-picker>

        <!--结束时间选择器-->
        <mt-datetime-picker
                ref="picker2"
                type="datetime"
                :start-date="startDate"
                @confirm="handleConfirmE">
        </mt-datetime-picker>

        <!--数量选择器-->
        <div class="custom-picker" v-show="isShowBtnModel">
            <transition name="btnModel">
                <div class="picker-box">
                    <div class="btns">
                        <button @click="isShowBtnModel = false">取消</button>
                        <button @click="isShowBtnModel = false">确认</button>
                    </div>
                    <mt-picker :slots="numberSlot" @change="onNumberChange" :visible-item-count="3"></mt-picker>
                </div>
            </transition>
        </div>

        <!--active sheet-->
        <mt-actionsheet
                :actions="actions"
                v-model="sheetVisible">
        </mt-actionsheet>


    </section>
    <v-footer></v-footer>
    <div class="loading" v-show="isShow">
    <mt-spinner :type="0" :size="60"></mt-spinner>
</div>
</div>
</body>
<script src="../static/plus/vue.js"></script>
<script src="../static/plus/eleme.js"></script>
<script src="../static/js/common.js"></script>
<script>
    window.onload = function () {
        var vm = new Vue({
            el: '#app',
            data: {
                isShow: true,
                sheetVisible: false,
                startDate: new Date(),
                isShowBtnModel: false,
                apply: {
                    department: '运输部', // 部门
                    applicant: '测试', // 申请人
                    applyTime: '2018-02-08 21:12',
                    area: 1, //地区
                    startArea: "重庆江北",
                    endArea: '贵州茅台镇',
                    num: 1,
                    carType: [],
                    startTime: '',
                    endTime: '',
                    reason: '原因'
                },
                carType: [
                    {type: 1, name: "小轿车", flag: false},
                    {type: 2, name: "越野车", flag: true},
                    {type: 3, name: "特种车", flag: true}
                ],
                area: null,
                numberSlot: [{
                    flex: 1,
                    values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14],
                    className: 'slot1'
                }],
                actions: []
            },
            methods: {
                goBack() {
                    history.go(-1);
                },
                onNumberChange(picker, values) {
                    this.apply.num = values[0];
                },
                changeCar(obj) {
                    var that = this;
                    that.carType.forEach(function (item, index) {
                        if (obj.type == item.type) {
                            that.carType[index].flag = !that.carType[index].flag;
                        }
                    })
                },
                selectArea(x) {
                    this.area = x;
                },
                applyBth() {

                },
                getBtnCode(e) {
                    console.log(e);
                },
                showStarTime(picker) {
                    this.$refs[picker].open();
                },
                handleConfirmS(value) {
                    this.apply.startTime = getDateTime(value);
                },
                handleConfirmE(value) {
                    this.apply.endTime = getDateTime(value);
                }
            },
            created() {

            },
            mounted() {
                setSectionHeight();
                this.isShow = false;
                this.actions = [
                    {name: '保存', method: this.getBtnCode},
                    {name: '提交', method: this.getBtnCode},
                    {name: '终止', method: this.getBtnCode},
                    {name: '查看流程图', method: this.getBtnCode},
                    {name: '删除', method: this.getBtnCode},
                    {name: '完成', method: this.getBtnCode}
                ]
            }
        });
    }
</script>
</html>